home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Source / GNU / cc / bi-parser.c < prev    next >
C/C++ Source or Header  |  1994-02-15  |  19KB  |  747 lines

  1.  
  2. /*  A Bison parser, made from bi-parser.y  */
  3.  
  4. #define    DEFOP    258
  5. #define    STRING    259
  6.  
  7. #line 21 "bi-parser.y"
  8.  
  9.  
  10. #include <stdio.h>
  11. #include "hconfig.h"
  12. #include "bi-defs.h"
  13.  
  14. extern char yytext[];
  15. extern int yyleng;
  16.  
  17.  
  18. /* Chain of all defs built by the parser. */
  19. struct def *defs;
  20. int ndefs;
  21.  
  22. static struct node *makenode ();
  23. static struct variation *makevar ();
  24. static struct def *makedef ();
  25.  
  26. void yyerror ();
  27.  
  28.  
  29. #line 43 "bi-parser.y"
  30. typedef union
  31. {
  32.   char *string;
  33.   struct def *def;
  34.   struct variation *variation;
  35.   struct node *node;
  36. } YYSTYPE;
  37.  
  38. #ifndef YYLTYPE
  39. typedef
  40.   struct yyltype
  41.     {
  42.       int timestamp;
  43.       int first_line;
  44.       int first_column;
  45.       int last_line;
  46.       int last_column;
  47.       char *text;
  48.    }
  49.   yyltype;
  50.  
  51. #define YYLTYPE yyltype
  52. #endif
  53.  
  54. #include <stdio.h>
  55.  
  56. #ifndef __STDC__
  57. #define const
  58. #endif
  59.  
  60.  
  61.  
  62. #define    YYFINAL        39
  63. #define    YYFLAG        -32768
  64. #define    YYNTBASE    8
  65.  
  66. #define YYTRANSLATE(x) ((unsigned)(x) <= 259 ? yytranslate[x] : 17)
  67.  
  68. static const char yytranslate[] = {     0,
  69.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  70.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  71.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  72.      2,     2,     2,     2,     2,     2,     2,     2,     2,     5,
  73.      7,     2,     2,     6,     2,     2,     2,     2,     2,     2,
  74.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  75.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  76.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  77.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  78.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  79.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  80.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  81.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  82.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  83.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  84.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  85.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  86.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  87.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  88.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  89.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  90.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  91.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  92.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  93.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  94.      2,     2,     2,     2,     2,     1,     2,     3,     4
  95. };
  96.  
  97. static const short yyrline[] = {     0,
  98.     59,    64,    66,    70,    75,    77,    81,    84,    86,    88,
  99.     92,    94,    97,   100,   104,   107,   111
  100. };
  101.  
  102. static const char * const yytname[] = {     0,
  103. "error","$illegal.","DEFOP","STRING","'('","','","')'","top"
  104. };
  105.  
  106. static const short yyr1[] = {     0,
  107.      8,     9,     9,    10,    11,    11,    12,    12,    12,    12,
  108.     13,    13,    14,    14,    15,    15,    16
  109. };
  110.  
  111. static const short yyr2[] = {     0,
  112.      1,     1,     2,    10,     1,     3,     3,     5,     7,     9,
  113.      0,     1,     3,     0,     1,     3,     1
  114. };
  115.  
  116. static const short yydefact[] = {     0,
  117.      0,     1,     2,     0,     3,     0,    11,    12,     0,     0,
  118.      0,    11,     0,     5,     0,     0,     0,    14,     7,     6,
  119.      4,     0,     0,    17,     0,    15,    14,     8,    13,     0,
  120.      0,    16,    14,     9,     0,    10,     0,     0,     0
  121. };
  122.  
  123. static const short yydefgoto[] = {    37,
  124.      2,     3,    13,    14,     9,    23,    25,    26
  125. };
  126.  
  127. static const short yypact[] = {     2,
  128.      6,     2,-32768,     8,-32768,     7,    10,-32768,     9,    11,
  129.     12,    10,    -5,-32768,    -3,    12,    13,    14,-32768,-32768,
  130. -32768,    17,     1,-32768,    15,    18,    14,-32768,-32768,    17,
  131.      3,-32768,    14,-32768,    16,-32768,    25,    26,-32768
  132. };
  133.  
  134. static const short yypgoto[] = {-32768,
  135. -32768,    27,-32768,    19,    20,   -27,   -12,-32768
  136. };
  137.  
  138.  
  139. #define    YYLAST        35
  140.  
  141.  
  142. static const short yytable[] = {    31,
  143.     16,    17,    18,    19,     1,    35,    27,    28,    33,    34,
  144.      4,     6,     7,     8,    10,    11,    12,    32,    22,    21,
  145.     24,    29,    36,    30,    38,    39,     0,     0,     5,     0,
  146.      0,    15,     0,     0,    20
  147. };
  148.  
  149. static const short yycheck[] = {    27,
  150.      6,     7,     6,     7,     3,    33,     6,     7,     6,     7,
  151.      5,     4,     6,     4,     6,     5,     5,    30,     5,     7,
  152.      4,     7,     7,     6,     0,     0,    -1,    -1,     2,    -1,
  153.     -1,    12,    -1,    -1,    16
  154. };
  155. #define YYPURE 1
  156.  
  157. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  158. #line 3 "bison.simple"
  159.  
  160. /* Skeleton output parser for bison,
  161.    Copyright (C) 1984 Bob Corbett and Richard Stallman
  162.  
  163.    This program is free software; you can redistribute it and/or modify
  164.    it under the terms of the GNU General Public License as published by
  165.    the Free Software Foundation; either version 1, or (at your option)
  166.    any later version.
  167.  
  168.    This program is distributed in the hope that it will be useful,
  169.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  170.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  171.    GNU General Public License for more details.
  172.  
  173.    You should have received a copy of the GNU General Public License
  174.    along with this program; if not, write to the Free Software
  175.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  176.  
  177.  
  178. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__)
  179. #include <alloca.h>
  180. #endif
  181.  
  182. /* This is the parser code that is written into each bison parser
  183.   when the %semantic_parser declaration is not specified in the grammar.
  184.   It was written by Richard Stallman by simplifying the hairy parser
  185.   used when %semantic_parser is specified.  */
  186.  
  187. /* Note: there must be only one dollar sign in this file.
  188.    It is replaced by the list of actions, each action
  189.    as one case of the switch.  */
  190.  
  191. #define yyerrok        (yyerrstatus = 0)
  192. #define yyclearin    (yychar = YYEMPTY)
  193. #define YYEMPTY        -2
  194. #define YYEOF        0
  195. #define YYFAIL        goto yyerrlab;
  196. #define YYACCEPT    return(0)
  197. #define YYABORT     return(1)
  198. #define YYERROR        goto yyerrlab
  199.  
  200. #define YYTERROR    1
  201. #define YYERRCODE    256
  202.  
  203. #ifndef YYIMPURE
  204. #define YYLEX        yylex()
  205. #endif
  206.  
  207. #ifndef YYPURE
  208. #define YYLEX        yylex(&yylval, &yylloc)
  209. #endif
  210.  
  211. /* If nonreentrant, generate the variables here */
  212.  
  213. #ifndef YYIMPURE
  214.  
  215. int    yychar;            /*  the lookahead symbol        */
  216. YYSTYPE    yylval;            /*  the semantic value of the        */
  217.                 /*  lookahead symbol            */
  218.  
  219. YYLTYPE yylloc;            /*  location data for the lookahead    */
  220.                 /*  symbol                */
  221.  
  222. int yynerrs;            /*  number of parse errors so far       */
  223. #endif  /* YYIMPURE */
  224.  
  225. #if YYDEBUG != 0
  226. int yydebug;            /*  nonzero means print parse trace    */
  227. /* Since this is uninitialized, it does not stop multiple parsers
  228.    from coexisting.  */
  229. #endif
  230.  
  231. /*  YYMAXDEPTH indicates the initial size of the parser's stacks    */
  232.  
  233. #ifndef    YYMAXDEPTH
  234. #define YYMAXDEPTH 200
  235. #endif
  236.  
  237. /*  YYMAXLIMIT is the maximum size the stacks can grow to
  238.     (effective only if the built-in stack extension method is used).  */
  239.  
  240. #ifndef YYMAXLIMIT
  241. #define YYMAXLIMIT 10000
  242. #endif
  243.  
  244.  
  245. #line 90 "bison.simple"
  246. int
  247. yyparse()
  248. {
  249.   register int yystate;
  250.   register int yyn;
  251.   register short *yyssp;
  252.   register YYSTYPE *yyvsp;
  253.   YYLTYPE *yylsp;
  254.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  255.   int yychar1;        /*  lookahead token as an internal (translated) token number */
  256.  
  257.   short    yyssa[YYMAXDEPTH];    /*  the state stack            */
  258.   YYSTYPE yyvsa[YYMAXDEPTH];    /*  the semantic value stack        */
  259.   YYLTYPE yylsa[YYMAXDEPTH];    /*  the location stack            */
  260.  
  261.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  262.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  263.   YYLTYPE *yyls = yylsa;
  264.  
  265.   int yymaxdepth = YYMAXDEPTH;
  266.  
  267. #ifndef YYPURE
  268.   int yychar;
  269.   YYSTYPE yylval;
  270.   YYLTYPE yylloc;
  271.   int yynerrs;
  272. #endif
  273.  
  274.   YYSTYPE yyval;        /*  the variable used to return        */
  275.                 /*  semantic values from the action    */
  276.                 /*  routines                */
  277.  
  278.   int yylen;
  279.  
  280. #if YYDEBUG != 0
  281.   if (yydebug)
  282.     fprintf(stderr, "Starting parse\n");
  283. #endif
  284.  
  285.   yystate = 0;
  286.   yyerrstatus = 0;
  287.   yynerrs = 0;
  288.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  289.  
  290.   /* Initialize stack pointers.
  291.      Waste one element of value and location stack
  292.      so that they stay on the same level as the state stack.  */
  293.  
  294.   yyssp = yyss - 1;
  295.   yyvsp = yyvs;
  296.   yylsp = yyls;
  297.  
  298. /* Push a new state, which is found in  yystate  .  */
  299. /* In all cases, when you get here, the value and location stacks
  300.    have just been pushed. so pushing a state here evens the stacks.  */
  301. yynewstate:
  302.  
  303.   *++yyssp = yystate;
  304.  
  305.   if (yyssp >= yyss + yymaxdepth - 1)
  306.     {
  307.       /* Give user a chance to reallocate the stack */
  308.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  309.       YYSTYPE *yyvs1 = yyvs;
  310.       YYLTYPE *yyls1 = yyls;
  311.       short *yyss1 = yyss;
  312.  
  313.       /* Get the current used size of the three stacks, in elements.  */
  314.       int size = yyssp - yyss + 1;
  315.  
  316. #ifdef yyoverflow
  317.       /* Each stack pointer address is followed by the size of
  318.      the data in use in that stack, in bytes.  */
  319.       yyoverflow("parser stack overflow",
  320.          &yyss1, size * sizeof (*yyssp),
  321.          &yyvs1, size * sizeof (*yyvsp),
  322.          &yyls1, size * sizeof (*yylsp),
  323.          &yymaxdepth);
  324.  
  325.       yyss = yyss1; yyvs = yyvs1; yyls = yyls1;
  326. #else /* no yyoverflow */
  327.       /* Extend the stack our own way.  */
  328.       if (yymaxdepth >= YYMAXLIMIT)
  329.     yyerror("parser stack overflow");
  330.       yymaxdepth *= 2;
  331.       if (yymaxdepth > YYMAXLIMIT)
  332.     yymaxdepth = YYMAXLIMIT;
  333.       yyss = (short *) alloca (yymaxdepth * sizeof (*yyssp));
  334.       bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  335.       yyvs = (YYSTYPE *) alloca (yymaxdepth * sizeof (*yyvsp));
  336.       bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  337. #ifdef YYLSP_NEEDED
  338.       yyls = (YYLTYPE *) alloca (yymaxdepth * sizeof (*yylsp));
  339.       bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  340. #endif
  341. #endif /* no yyoverflow */
  342.  
  343.       yyssp = yyss + size - 1;
  344.       yyvsp = yyvs + size - 1;
  345. #ifdef YYLSP_NEEDED
  346.       yylsp = yyls + size - 1;
  347. #endif
  348.  
  349. #if YYDEBUG != 0
  350.       if (yydebug)
  351.     fprintf(stderr, "Stack size increased to %d\n", yymaxdepth);
  352. #endif
  353.  
  354.       if (yyssp >= yyss + yymaxdepth - 1)
  355.     YYABORT;
  356.     }
  357.  
  358. #if YYDEBUG != 0
  359.   if (yydebug)
  360.     fprintf(stderr, "Entering state %d\n", yystate);
  361. #endif
  362.  
  363. /* Do appropriate processing given the current state.  */
  364. /* Read a lookahead token if we need one and don't already have one.  */
  365. yyresume:
  366.  
  367.   /* First try to decide what to do without reference to lookahead token.  */
  368.  
  369.   yyn = yypact[yystate];
  370.   if (yyn == YYFLAG)
  371.     goto yydefault;
  372.  
  373.   /* Not known => get a lookahead token if don't already have one.  */
  374.  
  375.   /* yychar is either YYEMPTY or YYEOF
  376.      or a valid token in external form.  */
  377.  
  378.   if (yychar == YYEMPTY)
  379.     {
  380. #if YYDEBUG != 0
  381.       if (yydebug)
  382.     fprintf(stderr, "Reading a token: ");
  383. #endif
  384.       yychar = YYLEX;
  385.     }
  386.  
  387.   /* Convert token to internal form (in yychar1) for indexing tables with */
  388.  
  389.   if (yychar <= 0)        /* This means end of input. */
  390.     {
  391.       yychar1 = 0;
  392.       yychar = YYEOF;        /* Don't call YYLEX any more */
  393.  
  394. #if YYDEBUG != 0
  395.       if (yydebug)
  396.     fprintf(stderr, "Now at end of input.\n");
  397. #endif
  398.     }
  399.   else
  400.     {
  401.       yychar1 = YYTRANSLATE(yychar);
  402.  
  403. #if YYDEBUG != 0
  404.       if (yydebug)
  405.     fprintf(stderr, "Next token is %d (%s)\n", yychar, yytname[yychar1]);
  406. #endif
  407.     }
  408.  
  409.   yyn += yychar1;
  410.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  411.     goto yydefault;
  412.  
  413.   yyn = yytable[yyn];
  414.  
  415.   /* yyn is what to do for this token type in this state.
  416.      Negative => reduce, -yyn is rule number.
  417.      Positive => shift, yyn is new state.
  418.        New state is final state => don't bother to shift,
  419.        just return success.
  420.      0, or most negative number => error.  */
  421.  
  422.   if (yyn < 0)
  423.     {
  424.       if (yyn == YYFLAG)
  425.     goto yyerrlab;
  426.       yyn = -yyn;
  427.       goto yyreduce;
  428.     }
  429.   else if (yyn == 0)
  430.     goto yyerrlab;
  431.  
  432.   if (yyn == YYFINAL)
  433.     YYACCEPT;
  434.  
  435.   /* Shift the lookahead token.  */
  436.  
  437. #if YYDEBUG != 0
  438.   if (yydebug)
  439.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  440. #endif
  441.  
  442.   /* Discard the token being shifted unless it is eof.  */
  443.   if (yychar != YYEOF)
  444.     yychar = YYEMPTY;
  445.  
  446.   *++yyvsp = yylval;
  447. #ifdef YYLSP_NEEDED
  448.   *++yylsp = yylloc;
  449. #endif
  450.  
  451.   /* count tokens shifted since error; after three, turn off error status.  */
  452.   if (yyerrstatus) yyerrstatus--;
  453.  
  454.   yystate = yyn;
  455.   goto yynewstate;
  456.  
  457. /* Do the default action for the current state.  */
  458. yydefault:
  459.  
  460.   yyn = yydefact[yystate];
  461.   if (yyn == 0)
  462.     goto yyerrlab;
  463.  
  464. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  465. yyreduce:
  466.   yylen = yyr2[yyn];
  467.   yyval = yyvsp[1-yylen]; /* implement default value of the action */
  468.  
  469. #if YYDEBUG != 0
  470.   if (yydebug)
  471.     {
  472.       if (yylen == 1)
  473.     fprintf (stderr, "Reducing 1 value via line %d, ",
  474.          yyrline[yyn]);
  475.       else
  476.     fprintf (stderr, "Reducing %d values via line %d, ",
  477.          yylen, yyrline[yyn]);
  478.     }
  479. #endif
  480.  
  481.  
  482.   switch (yyn) {
  483.  
  484. case 1:
  485. #line 61 "bi-parser.y"
  486. { defs = yyvsp[0].def; ;
  487.     break;}
  488. case 3:
  489. #line 67 "bi-parser.y"
  490. { yyvsp[0].def->next = yyvsp[-1].def; yyval.def = yyvsp[0].def; ;
  491.     break;}
  492. case 4:
  493. #line 72 "bi-parser.y"
  494. { yyval.def = makedef (yyvsp[-7].string, yyvsp[-5].string, yyvsp[-2].variation); ;
  495.     break;}
  496. case 6:
  497. #line 78 "bi-parser.y"
  498. { yyvsp[0].variation->next = yyvsp[-2].variation; yyval.variation = yyvsp[0].variation; ;
  499.     break;}
  500. case 7:
  501. #line 83 "bi-parser.y"
  502. { yyval.variation = makevar (yyvsp[-1].string, (struct node *) NULL, (struct node *) NULL, (struct node *) NULL); ;
  503.     break;}
  504. case 8:
  505. #line 85 "bi-parser.y"
  506. { yyval.variation = makevar (yyvsp[-3].string, yyvsp[-1].node, (struct node *) NULL, (struct node *) NULL); ;
  507.     break;}
  508. case 9:
  509. #line 87 "bi-parser.y"
  510. { yyval.variation = makevar (yyvsp[-5].string, yyvsp[-3].node, yyvsp[-1].node, (struct node *) NULL); ;
  511.     break;}
  512. case 10:
  513. #line 89 "bi-parser.y"
  514. { yyval.variation = makevar (yyvsp[-7].string, yyvsp[-5].node, yyvsp[-3].node, yyvsp[-1].node); ;
  515.     break;}
  516. case 11:
  517. #line 93 "bi-parser.y"
  518. { yyval.string = ""; ;
  519.     break;}
  520. case 12:
  521. #line 94 "bi-parser.y"
  522. { yyval.string = yyvsp[0].string; ;
  523.     break;}
  524. case 13:
  525. #line 99 "bi-parser.y"
  526. { yyval.node = yyvsp[-1].node; ;
  527.     break;}
  528. case 14:
  529. #line 101 "bi-parser.y"
  530. { yyval.node = NULL; ;
  531.     break;}
  532. case 16:
  533. #line 108 "bi-parser.y"
  534. { yyvsp[-2].node->next = yyvsp[0].node; yyval.node = yyvsp[-2].node; ;
  535.     break;}
  536. case 17:
  537. #line 113 "bi-parser.y"
  538. { yyval.node = makenode (yyvsp[0].string); ;
  539.     break;}
  540. }
  541.    /* the action file gets copied in in place of this dollarsign */
  542. #line 327 "bison.simple"
  543.  
  544.   yyvsp -= yylen;
  545.   yyssp -= yylen;
  546. #ifdef YYLSP_NEEDED
  547.   yylsp -= yylen;
  548. #endif
  549.  
  550. #if YYDEBUG != 0
  551.   if (yydebug)
  552.     {
  553.       short *ssp1 = yyss - 1;
  554.       fprintf (stderr, "state stack now");
  555.       while (ssp1 != yyssp)
  556.     fprintf (stderr, " %d", *++ssp1);
  557.       fprintf (stderr, "\n");
  558.     }
  559. #endif
  560.  
  561.   *++yyvsp = yyval;
  562.  
  563. #ifdef YYLSP_NEEDED
  564.   yylsp++;
  565.   if (yylen == 0)
  566.     {
  567.       yylsp->first_line = yylloc.first_line;
  568.       yylsp->first_column = yylloc.first_column;
  569.       yylsp->last_line = (yylsp-1)->last_line;
  570.       yylsp->last_column = (yylsp-1)->last_column;
  571.       yylsp->text = 0;
  572.     }
  573.   else
  574.     {
  575.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  576.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  577.     }
  578. #endif
  579.  
  580.   /* Now "shift" the result of the reduction.
  581.      Determine what state that goes to,
  582.      based on the state we popped back to
  583.      and the rule number reduced by.  */
  584.  
  585.   yyn = yyr1[yyn];
  586.  
  587.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  588.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  589.     yystate = yytable[yystate];
  590.   else
  591.     yystate = yydefgoto[yyn - YYNTBASE];
  592.  
  593.   goto yynewstate;
  594.  
  595. yyerrlab:   /* here on detecting error */
  596.  
  597.   if (! yyerrstatus)
  598.     /* If not already recovering from an error, report this error.  */
  599.     {
  600.       ++yynerrs;
  601.       yyerror("parse error");
  602.     }
  603.  
  604.   if (yyerrstatus == 3)
  605.     {
  606.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  607.  
  608.       /* return failure if at end of input */
  609.       if (yychar == YYEOF)
  610.     YYABORT;
  611.  
  612. #if YYDEBUG != 0
  613.       if (yydebug)
  614.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  615. #endif
  616.  
  617.       yychar = YYEMPTY;
  618.     }
  619.  
  620.   /* Else will try to reuse lookahead token
  621.      after shifting the error token.  */
  622.  
  623.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  624.  
  625.   goto yyerrhandle;
  626.  
  627. yyerrdefault:  /* current state does not do anything special for the error token. */
  628.  
  629. #if 0
  630.   /* This is wrong; only states that explicitly want error tokens
  631.      should shift them.  */
  632.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  633.   if (yyn) goto yydefault;
  634. #endif
  635.  
  636. yyerrpop:   /* pop the current state because it cannot handle the error token */
  637.  
  638.   if (yyssp == yyss) YYABORT;
  639.   yyvsp--;
  640.   yystate = *--yyssp;
  641. #ifdef YYLSP_NEEDED
  642.   yylsp--;
  643. #endif
  644.  
  645. #if YYDEBUG != 0
  646.   if (yydebug)
  647.     {
  648.       short *ssp1 = yyss - 1;
  649.       fprintf (stderr, "Error: state stack now");
  650.       while (ssp1 != yyssp)
  651.     fprintf (stderr, " %d", *++ssp1);
  652.       fprintf (stderr, "\n");
  653.     }
  654. #endif
  655.  
  656. yyerrhandle:
  657.  
  658.   yyn = yypact[yystate];
  659.   if (yyn == YYFLAG)
  660.     goto yyerrdefault;
  661.  
  662.   yyn += YYTERROR;
  663.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  664.     goto yyerrdefault;
  665.  
  666.   yyn = yytable[yyn];
  667.   if (yyn < 0)
  668.     {
  669.       if (yyn == YYFLAG)
  670.     goto yyerrpop;
  671.       yyn = -yyn;
  672.       goto yyreduce;
  673.     }
  674.   else if (yyn == 0)
  675.     goto yyerrpop;
  676.  
  677.   if (yyn == YYFINAL)
  678.     YYACCEPT;
  679.  
  680. #if YYDEBUG != 0
  681.   if (yydebug)
  682.     fprintf(stderr, "Shifting error token, ");
  683. #endif
  684.  
  685.   *++yyvsp = yylval;
  686. #ifdef YYLSP_NEEDED
  687.   *++yylsp = yylloc;
  688. #endif
  689.  
  690.   yystate = yyn;
  691.   goto yynewstate;
  692. }
  693. #line 116 "bi-parser.y"
  694.  
  695.  
  696. static struct node *
  697. makenode (s)
  698.      char *s;
  699. {
  700.   struct node *n;
  701.  
  702.   n = (struct node *) malloc (sizeof (struct node));
  703.   n->text = s;
  704.   n->next = NULL;
  705.   return n;
  706. }
  707.  
  708. static struct variation *
  709. makevar (name, inputs, outputs, literals)
  710.      char *name;
  711.      struct node *inputs, *outputs, *literals;
  712. {
  713.   struct variation *v;
  714.  
  715.   v = (struct variation *) malloc (sizeof (struct variation));
  716.   v->name = name;
  717.   v->code = ndefs++;
  718.   v->inputs = inputs;
  719.   v->outputs = outputs;
  720.   v->literals = literals;
  721.   v->next = NULL;
  722.   return v;
  723. }
  724.  
  725. static struct def *
  726. makedef (name, template, vars)
  727.      char *name, *template;
  728.      struct variation *vars;
  729. {
  730.   struct def *d;
  731.  
  732.   d = (struct def *) malloc (sizeof (struct def));
  733.   d->basename = name;
  734.   d->template = template;
  735.   d->variations = vars;
  736.   d->next = NULL;
  737.   return d;
  738. }
  739.  
  740. void
  741. yyerror (s)
  742.      char *s;
  743. {
  744.   fprintf (stderr, "syntax error in input\n");
  745.   exit (FATAL_EXIT_CODE);
  746. }
  747.